/*
 *-----------------------------------------------------------------------------
 * The confidential and proprietary information contained in this file may
 * only be used by a person authorised under and to the extent permitted
 * by a subsisting licensing agreement from  CHIPSEA.
 *
 *            (C) COPYRIGHT 2015 SHENZHEN CHIPSEA TECHNOLOGIES CO.,LTD.
 *                ALL RIGHTS RESERVED
 *
 * This entire notice must be reproduced on all copies of this file
 * and copies of this file may only be made by a person if such person is
 * permitted to do so under the terms of a subsisting license agreement
 * from CHIPSEA.
 *
 *      Release Information : CSA37FX60 
 *-----------------------------------------------------------------------------
 */

#include "compile_option.h"

#ifdef CS_F60

#ifndef __CSA37FX60_I2C_H
#define __CSA37FX60_I2C_H

#include "csa37fx60.h"
#include "absacc.h"
#include "csa37fx60_lib.h"

typedef enum
{ 
    I2C_MAT_SAR = 0x8000,
    I2C_MST_ON_HOLD = 0x2000,
    I2C_R_RESTART = 0x1000,
    I2C_GEN_CALL = 0x0800,
    I2C_R_START = 0x0400,
    I2C_R_STOP = 0x0200,
    I2C_ACTIVITY = 0x0100,
    I2C_RX_DONE = 0x0080,
    I2C_TX_ABRT = 0x0040,
    I2C_RD_REQ = 0x0020,
    I2C_TX_EMPTY = 0x0010,
    I2C_TX_OVER = 0x0008,
    I2C_RX_FULL = 0x0004,
    I2C_RX_OVER = 0x0002,
    I2C_RX_UNDER = 0x0001,
    
}I2C_IntMode_TypeDef;

//typedef enum
//{ 
//    I2C_MAT_SAR = BIT(15),
//    I2C_MST_ON_HOLD = BIT(13),
//    I2C_RESTART_DET = BIT(12),
//    I2C_GEN_CALL = BIT(11),
//    I2C_START_DET = BIT(10),
//    I2C_STOP_DET = BIT(9),
//    I2C_ACTIVITY = BIT(8),
//    I2C_RX_DONE = BIT(7),
//    I2C_TX_ABRT = BIT(6),
//    I2C_RD_REQ = BIT(5),
//    I2C_TX_EMPTY = BIT(4),
//    I2C_TX_OVER = BIT(3),
//    I2C_RX_FULL = BIT(2),
//    I2C_RX_OVER = BIT(1),
//    I2C_RX_UNDER = BIT(0),
//    
//}I2C_IntMode_TypeDef;

//typedef enum
//{ 
//    I2C_MAT_SAR = 0x0f,
////     I2C_RX_DONE = 0x07,
//    I2C_RD_REQ = 0x05,
//    I2C_RX_FULL = 0x02,
//    
//}I2C_IntMode_TypeDef;

typedef struct
{
    uint8_t I2C_Addr;
    uint8_t I2C_RX_FIFO_Level;
    uint8_t I2C_TX_FIFO_Level;
    
}I2C_InitTypeDef;

extern uint8_t AFE0_UserSampleNum[16] ;
extern uint8_t AFE1_UserSampleNum[16] ;

void I2C_Salve_Init(I2C_InitTypeDef* I2C_InitStruct);
void I2C_SendByte(uint8_t dat);
void I2C_SendMoreByte(uint8_t *dat, uint8_t num);
uint8_t I2C_RxFIFONum(void);
uint8_t I2C_ReadByte(void);
uint32_t I2C_ReadInt_State(I2C_IntMode_TypeDef I2C_IntMode);
void I2C_IntAllDisable(void);
void I2C_IntModeEnable(uint32_t I2C_IntMode);
void I2C_ClearAllIntState(void);
void I2C_Enable(void);
void I2C_Disable(void);
void I2C_ClearIntState(I2C_IntMode_TypeDef I2C_IntMode);

#endif /* __CSA37FX60_I2C_H */

#endif /* End of CS_F60 */
